From 5f3ea879daef77afb803af1e4d0443514b42a8e7 Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 10 Oct 2002 17:16:43 +0000 Subject: [PATCH] adds Topo! support and implements mkshort in .psp, .mxf, and .ozi. From Alex Mottram. --- gpsbabel/Makefile | 3 ++- gpsbabel/mxf.c | 36 +++++++++++++++++++++++--------- gpsbabel/ozi.c | 36 ++++++++++++++++++++++++-------- gpsbabel/psp.c | 41 ++++++++++++++++++++++--------------- gpsbabel/reference/tpg.tpg | Bin 0 -> 577 bytes gpsbabel/testo | 11 ++++++++++ gpsbabel/vecs.c | 6 ++++++ 7 files changed, 98 insertions(+), 35 deletions(-) create mode 100644 gpsbabel/reference/tpg.tpg diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index f132b4a21..b83592c6b 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -2,7 +2,7 @@ CFLAGS=-g -Icoldsync FMTS=magproto.o gpx.o geo.o gpsman.o mapsend.o mapsource.o \ gpsutil.o tiger.o pcx.o csv.o cetus.o gpspilot.o magnav.o \ - psp.o mxf.o holux.o garmin.o ozi.o dna.o + psp.o mxf.o holux.o garmin.o ozi.o dna.o tpg.o JEEPS=jeeps/gpsapp.o jeeps/gpscom.o jeeps/gpsfmt.o jeeps/gpsinput.o \ jeeps/gpsmath.o jeeps/gpsmem.o \ @@ -57,6 +57,7 @@ mapsource.o: mapsource.c defs.h queue.h mkshort.o: mkshort.c defs.h queue.h mxf.o: mxf.c defs.h queue.h csv_util.h ozi.o: ozi.c defs.h queue.h csv_util.h +tpg.o: tpg.c defs.h queue.h pcx.o: pcx.c defs.h queue.h psp.o: psp.c defs.h queue.h queue.o: queue.c queue.h diff --git a/gpsbabel/mxf.c b/gpsbabel/mxf.c index e5399b467..412fa69a1 100644 --- a/gpsbabel/mxf.c +++ b/gpsbabel/mxf.c @@ -148,20 +148,30 @@ mxf_waypt_pr(const waypoint * wpt) char *shortname = NULL; char *description = NULL; - if (wpt->shortname) { + if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { + if (wpt->description) { + if (global_opts.synthesize_shortnames) + shortname = mkshort(wpt->description); + else + shortname = csv_stringclean(wpt->description, ",\""); + } else { + /* no description available */ + shortname = xstrdup(""); + } + } else{ shortname = csv_stringclean(wpt->shortname, ",\""); - shortname = csv_stringtrim(shortname, ""); - } else { - shortname = xstrdup(""); } - - if (wpt->description) { + + if (! wpt->description) { + if (shortname) { + description = csv_stringclean(shortname, ",\""); + } else { + description = xstrdup(""); + } + } else{ description = csv_stringclean(wpt->description, ",\""); - description = csv_stringtrim(description, ""); - } else { - shortname = xstrdup(""); } - + fprintf(file_out, "%08.5f, %08.5f, \"%s\", \"%s\", \"%s\", %s, %d\n", wpt->position.latitude.degrees, wpt->position.longitude.degrees, description, shortname, description, @@ -176,6 +186,12 @@ mxf_waypt_pr(const waypoint * wpt) static void data_write(void) { + if (global_opts.synthesize_shortnames) { + setshort_length(32); + setshort_whitespace_ok(0); + setshort_badchars("\","); + } + waypt_disp_all(mxf_waypt_pr); } diff --git a/gpsbabel/ozi.c b/gpsbabel/ozi.c index 7fb507314..d04699bf7 100644 --- a/gpsbabel/ozi.c +++ b/gpsbabel/ozi.c @@ -183,15 +183,29 @@ ozi_waypt_pr(const waypoint * wpt) ozi_time = (wpt->creation_time / 86400.0) + 25569.0; alt_feet = (wpt->position.altitude.altitude_meters * 3.2808); - if (wpt->description) - description = csv_stringclean(wpt->description, ","); - else - description = xstrdup(""); - - if (wpt->shortname) + if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { + if (wpt->description) { + if (global_opts.synthesize_shortnames) + shortname = mkshort(wpt->description); + else + shortname = csv_stringclean(wpt->description, ","); + } else { + /* no description available */ + shortname = xstrdup(""); + } + } else{ shortname = csv_stringclean(wpt->shortname, ","); - else - shortname = xstrdup(""); + } + + if (! wpt->description) { + if (shortname) { + description = csv_stringclean(shortname, ","); + } else { + description = xstrdup(""); + } + } else{ + description = csv_stringclean(wpt->description, ","); + } index++; @@ -214,6 +228,12 @@ data_write(void) fprintf(file_out, "Reserved 2\n"); fprintf(file_out, "Reserved 3\n"); + if (global_opts.synthesize_shortnames) { + setshort_length(32); + setshort_whitespace_ok(0); + setshort_badchars("\","); + } + waypt_disp_all(ozi_waypt_pr); } diff --git a/gpsbabel/psp.c b/gpsbabel/psp.c index 1d94ebce3..5e4773a80 100644 --- a/gpsbabel/psp.c +++ b/gpsbabel/psp.c @@ -331,26 +331,30 @@ psp_waypt_pr(const waypoint *wpt) int i; char *shortname; char *description; - - /* this output format pretty much requires a description - * and a shortname - */ - - if (wpt->shortname) { - shortname = xstrdup(wpt->shortname); - } else { - if (wpt->description) - shortname = xstrdup(wpt->description); - else + if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { + if (wpt->description) { + if (global_opts.synthesize_shortnames) + shortname = mkshort(wpt->description); + else + shortname = xstrdup(wpt->description); + } else { + /* no description available */ shortname = xstrdup(""); + } + } else{ + shortname = xstrdup(wpt->shortname); } - - if (wpt->description) { + + if (! wpt->description) { + if (shortname) { + description = xstrdup(shortname); + } else { + description = xstrdup(""); + } + } else{ description = xstrdup(wpt->description); - } else { - description = xstrdup(shortname); - } + } /* convert lat/long back to radians */ lat = (wpt->position.latitude.degrees * M_PI) / 180.0; @@ -431,6 +435,11 @@ psp_write(void) /* offset 0x0C - 0x0D = 2 byte pin count */ s = waypt_count(); + + if (global_opts.synthesize_shortnames) { + setshort_length(32); + setshort_whitespace_ok(1); + } if (s > MAXPSPOUTPUTPINS) { fatal(MYNAME ": attempt to output too many pushpins (%d). The max is %d. Sorry.\n", s, MAXPSPOUTPUTPINS); diff --git a/gpsbabel/reference/tpg.tpg b/gpsbabel/reference/tpg.tpg new file mode 100644 index 0000000000000000000000000000000000000000..a9a01a292ecc85bab249a87221b79e28ca19faca GIT binary patch literal 577 zcmd;N`2U}gftSHKB)=d(Jh8GMKQpg{)!o_E$>|ff!rOT#LLL6{J}%4nQIN@ z>Rn|sxSgQ-?uXEDv=s zzQxwx^dDxutV?EDs)AE~Zc=Iy$N;Z=_kdua<}`$6BU499UO^fC=9QriC4zT9ykvpd zE#c-L9O4>;tPjajBXc8T3+ocU%JrcRZjOKdMDW4%Df#55C*~>mWTt17WaO6?r$S9A zC`NU*k(0UM#p$UGGd6`fEZSsx(SQSHf`ofwUMA4R&WXuD?*rW(j2v3V29|E$%!{vG z+8pZ8;BN5P0v=j&!5Nk6#R?vokl=F5EJ}3)xgxd5H80&564u6s=8hk_m6nU`40VY7 zDk>hy4zpF>J+q{wGPD5UVSR=0#G*W)Ljn?uvWvlC4b<*Z?4q`{aeJu4wd3!Vrg6cv QD|zPSfGo?*OUG>j0EY0qIRF3v literal 0 HcmV?d00001 diff --git a/gpsbabel/testo b/gpsbabel/testo index 004048717..307895142 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -93,6 +93,17 @@ ${PNAME} -i mxf -f reference/mxf.mxf -o mxf -F ${TMPDIR}/mx.mxf ${PNAME} -i mxf -f ${TMPDIR}/mx.mxf -o mxf -F ${TMPDIR}/mxf.mxf diff ${TMPDIR}/mxf.mxf reference +# TPG (NG Topo!) file format +# This is hard to test as the datum conversions create minute +# inconsistencies in the coordinates. So.. we test our i/o +# against a format that rounds higher than we care to compare +# for binary data. +rm -f ${TMPDIR}/topo.mxf ${TMPDIR}/tpg.mxf ${TMPDIR}/geo.tpg +${PNAME} -i geo -f geocaching.loc -o tpg -F ${TMPDIR}/geo.tpg +${PNAME} -i tpg -f ${TMPDIR}/geo.tpg -o mxf -F ${TMPDIR}/tpg.mxf +${PNAME} -i tpg -f reference/tpg.tpg -o mxf -F ${TMPDIR}/topo.mxf +diff ${TMPDIR}/tpg.mxf ${TMPDIR}/topo.mxf + # OZI (OziExplorer 1.1) file format rm -f ${TMPDIR}/oz.ozi ${TMPDIR}/ozi.ozi ${PNAME} -i ozi -f reference/ozi.ozi -o ozi -F ${TMPDIR}/oz.ozi diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index db1e0691d..2735bc5a5 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -45,6 +45,7 @@ extern ff_vecs_t garmin_vecs; extern ff_vecs_t mxf_vecs; extern ff_vecs_t holux_vecs; extern ff_vecs_t ozi_vecs; +extern ff_vecs_t tpg_vecs; extern ff_vecs_t dna_vecs; extern ff_vecs_t xmap_vecs; @@ -145,6 +146,11 @@ vecs_t vec_list[] = { "ozi", "OziExplorer Waypoint" }, + { + &tpg_vecs, + "tpg", + "National Geographic Topo .tpg" + }, { NULL, -- 2.30.2